package com.inke.box.setting;



import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.View;
import android.widget.Button;
import android.widget.FrameLayout;

import com.inke.box.R;
import com.inke.box.setting.Fragment.basicsstting.BasicsSttingFragment;
import com.inke.box.setting.seatsetting.SeatSettingFragment;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import mvp.MVPBaseActivity;


/**
 * MVPPlugin
 * 邮箱 784787081@qq.com
 */

public class SettingActivity extends MVPBaseActivity<SettingContract.View, SettingPresenter> implements SettingContract.View {
    @BindView(R.id.basic_setting)
    Button basicSetting;
    @BindView(R.id.sprint_setting)
    Button sprintSetting;
    @BindView(R.id.product_setting)
    Button productSetting;
    @BindView(R.id.seat_setting)
    Button seatSetting;
    @BindView(R.id.framelayout_setting)
    FrameLayout framelayoutSetting;
    private BasicsSttingFragment mBasicsSttingFragment;
    private SeatSettingFragment mSeatSettingFragment;

    //
//    @BindView(R.id.setting_viewpager)
//    ViewPager mSettingViewpager;
//    @BindView(R.id.setting_tblayout)
//    TabLayout mSettingTblayout;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initView();
    }

    private void initView() {
        setContentView(R.layout.activity_basic_sttings2);
        ButterKnife.bind(this);
        mBasicsSttingFragment = new BasicsSttingFragment();
        mSeatSettingFragment = new SeatSettingFragment();
        addFragment(mBasicsSttingFragment,"BasicsSttingFragment");
//        SettingMainAdapter mainAdapter=new SettingMainAdapter(getSupportFragmentManager(),getContext());
//        mainAdapter.setTabTitle(R.array.setting_viewpage_arrays);
//        mainAdapter.addPage(BasicsSttingFragment.class);
//        mainAdapter.addPage(BasicsSttingFragment.class);
//        mainAdapter.addPage(BasicsSttingFragment.class);
//        mainAdapter.addPage(BasicsSttingFragment.class);
//        mSettingViewpager.setAdapter(mainAdapter);
//        mSettingTblayout.setupWithViewPager(mSettingViewpager);
    }

    @OnClick({R.id.basic_setting, R.id.sprint_setting, R.id.product_setting, R.id.seat_setting})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.basic_setting:
                replaceFragment(mBasicsSttingFragment);
                break;
            case R.id.sprint_setting:
                replaceFragment(mSeatSettingFragment);
                break;
            case R.id.product_setting:
                replaceFragment(mBasicsSttingFragment);
                break;
            case R.id.seat_setting:
                replaceFragment(mSeatSettingFragment);
                break;
        }
    }
    private void addFragment(Fragment fragment, String tag) {
        FragmentManager manager = getSupportFragmentManager();
        FragmentTransaction transaction = manager.beginTransaction();
        transaction.add(R.id.framelayout_setting, fragment, tag).commit();

    }
    private void replaceFragment(Fragment fragment) {
        FragmentManager manager = getSupportFragmentManager();
        FragmentTransaction transaction = manager.beginTransaction();
        transaction.replace(R.id.framelayout_setting, fragment).commit();

    }
}
